﻿using System;
using System.IO;

namespace WPFNote.Utilities.Common
{
    public static class AppSession
    {
        /*
         *{"UserName":"fhy","NickName":"BlackvonCode","Phone":"17636541987","Email":"blackvon@163.com","OpenId":"50d4a15a736e467dbff319183fc1cc93","Id":1,"PostTime":"2021-10-21T22:57:29"}
         * 
         */
        public static Models.Users UserInfo { get; set; }

        public static Models.TokenJson Token { get; set; }

        public static Models.Enum.ContentType CategoryType = Models.Enum.ContentType.Note;
        
        public const string AppName = "BlackvonNote";
        
        public const string DbFileName = AppName + ".db";
        public static string ConfigPath => Path.Combine(BaseDirectory, "config");
        public static string UserInfoPath => Path.Combine(BaseDirectory, "userInfo");
        public static string DbPath => Path.Combine(BaseDirectory, DbFileName);
        public static string DbBackUpPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "database");
        
        public const string ZipFileName = "BlackvonNote-Database.zip";

        public static string BaseDirectory
        {
            get
            {
                string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                string folder = System.IO.Path.Combine(programDataPath, ".BlackvonNote");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                    File.SetAttributes(folder, FileAttributes.Hidden);
                }
                return folder;
            }
        }
    }
}